﻿using System;
using System.Collections.Generic;
using System.Text;
using NIIT.SaoBacDau.Aupi.HospitalManagement.Entities;
using System.Data.SqlClient;
using System.Data;
namespace NIIT.SaoBacDau.Aupi.HospitalManagement.DataAccess
{
    public class DAO_DetailsMedical
    {
        public static Obj_DetailsMedical DetailsMedical()
        {
            SqlDataAdapter sqlda = new SqlDataAdapter("Patient.DetailsMedicalID", DAO_ConnectDatabase.Connect());
            sqlda.SelectCommand.CommandType = CommandType.StoredProcedure;
            DataTable dtable = new DataTable();
            sqlda.Fill(dtable);
            Obj_DetailsMedical dm = new Obj_DetailsMedical();
            dm.DetailsMedicalID = dtable.Rows.Count;
            return dm;
        }

        public static void AddDetailsMedical(Obj_DetailsMedical detailsMedical)
        {
            SqlConnection sc = DAO_ConnectDatabase.Connect();
            try
            {
                sc.Open();
                SqlCommand sqlcom = new SqlCommand("Patient.AddQuickDetailsMedical", sc);
                sqlcom.CommandType = CommandType.StoredProcedure;
                sqlcom.Parameters.Add("@DetailsMedicalID ", SqlDbType.Int).Value = detailsMedical.DetailsMedicalID;
                sqlcom.Parameters.Add("@PatientID", SqlDbType.Int).Value = detailsMedical.PatientID;
                sqlcom.ExecuteNonQuery();
            }
            finally
            {
                if (sc.State == ConnectionState.Open)
                    sc.Close();
            }
        }
    }
}
